Python 3.11.0 | packaged by conda-forge | (main, Jan 16 2023, 14:12:30) [MSC v.1916 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.12.2 -- An enhanced Interactive Python. Type '?' for help.
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import griddata
import lmfit
from lmfit.lineshapes import gaussian2d, lorentzian
from PIL import Image
# image_path = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\VeffMeasurements\tests\0p4_82_exp100.jpg" # Replace with the actual image path
# image = Image.open(image_path)
# image_array = np.array(image)
# roi = image_array[:, :]
# plt.imshow(roi)
def fit_gaussian2d(image_data, title_og='Original Image', title_fit='Fitted Image'):
x = np.arange(image_data.shape[0])
y = np.arange(image_data.shape[1])
X,Y = np.meshgrid(x,y)
# def rot_gaussian2D(x,y, amplitude=1, centerx=0, centery=0,
# sigmax=1, sigmay=1):
# rotation=0
# xp = (x - centerx)*np.cos(rotation) - (y - centery)*np.sin(rotation)
# yp = (x - centerx)*np.sin(rotation) + (y - centery)*np.cos(rotation)
# return gaussian2d(xp, yp, amplitude=amplitude, centerx=centerx, centery=centery, sigmax=sigmax, sigmay=sigmay)
# model = lmfit.Model(rot_gaussian2D, independent_vars=['x', 'y'])
# params = model.make_params(amplitude=15723, centerx=X.ravel()[np.argmax(image_data.ravel())], \
# centery=Y.ravel()[np.argmax(image_data.ravel())], sigmax=5, sigmay=5)
model = lmfit.models.Gaussian2dModel()
params = model.guess(image_data.ravel(), X.ravel(), Y.ravel())
result = model.fit(image_data.ravel(), x=X.ravel(), y=Y.ravel(), params=params)
lmfit.report_fit(result)
plt.subplot(121)
plt.imshow(image_data)
plt.title(title_og)
plt.subplot(122)
plt.imshow(result.best_fit.reshape(len(y), len(x)))
plt.title(title_fit)
return result.best_values
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import griddata
import lmfit
from lmfit.lineshapes import gaussian2d, lorentzian
from PIL import Image
# Load the image
image_path = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\VeffMeasurements\Sept26Dispensation\1p85_82_e20.jpg" # Replace with the actual image path
image = Image.open(image_path)
# Convert the image to a numpy array
image_array = np.array(image)
plt.imshow(image_array)
plt.plot(image_array[:, 62])
[<matplotlib.lines.Line2D at 0x222c2919550>]
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import griddata
import os
from os.path import join as join
import lmfit
from lmfit.lineshapes import gaussian2d, lorentzian
from PIL import Image
# Load the image
run_folder = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\VeffMeasurements\Sept26Dispensation"
for i, img in enumerate(os.listdir(run_folder)[:]):
if 'e20' in img:
image_path = join(run_folder, img)
image = Image.open(image_path)
# Convert the image to a numpy array
image_array = np.array(image, dtype=float)
plot_data = image_array[32, 40:]
plt.plot(plot_data - plot_data[-1], label=f'{img}')
plt.legend(bbox_to_anchor=(1.5, 1.5))
<matplotlib.legend.Legend at 0x222c4ef8610>
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import griddata
import os
from os.path import join as join
import lmfit
from lmfit.lineshapes import gaussian2d, lorentzian
from PIL import Image
# Load the image
run_folder = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\VeffMeasurements\Sept26Dispensation"
for i, img in enumerate(os.listdir(run_folder)[:]):
if '1p12' in img:
image_path = join(run_folder, img)
image = Image.open(image_path)
# Convert the image to a numpy array
image_array = np.array(image, dtype=float)
plot_data = image_array[32, 40:]
plt.plot(plot_data/plot_data[-1], label=f'{img}')
plt.legend(bbox_to_anchor=(1.5, 1.5))
<matplotlib.legend.Legend at 0x222c4005b10>
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import griddata
import os
from os.path import join as join
import lmfit
from lmfit.lineshapes import gaussian2d, lorentzian
from PIL import Image
# Load the image
run_folder = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\VeffMeasurements\Sept26Dispensation"
for i, img in enumerate(os.listdir(run_folder)[:]):
if '1p12' in img:
image_path = join(run_folder, img)
image = Image.open(image_path)
# Convert the image to a numpy array
image_array = np.array(image, dtype=float)
plot_data = image_array[32, 40:]
plt.plot(plot_data/plot_data[0], label=f'{img}')
plt.legend(bbox_to_anchor=(1.5, 1.5))
<matplotlib.legend.Legend at 0x222b97242d0>
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import griddata
import os
from os.path import join as join
import lmfit
from lmfit.lineshapes import gaussian2d, lorentzian
from PIL import Image
# Load the image
run_folder = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\VeffMeasurements\Sept26Dispensation"
for i, img in enumerate(os.listdir(run_folder)[:]):
if '0p76' in img:
image_path = join(run_folder, img)
image = Image.open(image_path)
# Convert the image to a numpy array
image_array = np.array(image, dtype=float)
plot_data = image_array[32, 40:]
plt.plot(plot_data/plot_data[0], label=f'{img}')
plt.legend(bbox_to_anchor=(1.5, 1.5))
<matplotlib.legend.Legend at 0x222c5365810>
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import griddata
import os
from os.path import join as join
import lmfit
from lmfit.lineshapes import gaussian2d, lorentzian
from PIL import Image
# Load the image
run_folder = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\VeffMeasurements\Sept26Dispensation"
for i, img in enumerate(os.listdir(run_folder)[:]):
if '_84_' in img:
image_path = join(run_folder, img)
image = Image.open(image_path)
# Convert the image to a numpy array
image_array = np.array(image, dtype=float)
plot_data = image_array[32, 40:]
plt.plot(plot_data/plot_data[0], label=f'{img}')
plt.legend(bbox_to_anchor=(1.5, 1.5))
<matplotlib.legend.Legend at 0x222c54061d0>
image_path = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\VeffMeasurements\Sept26Dispensation\1p4_84_e20.jpg"
image = Image.open(image_path)
image_array = np.array(image, dtype=float)
plot_data = image_array[32, 40:]
plot_data = plot_data - plot_data[-1]
plt.imshow(image_array)
plt.show()
plt.close()
plt.plot(plot_data)
y = plot_data
x = np.arange(len(plot_data))
model = lmfit.models.GaussianModel()
params = model.guess(y, x=x)
result = model.fit(y, x=x, params=params)
result.fit_report()
plt.plot(x, y)
plt.plot(x, result.init_fit, '--', label='initial fit')
plt.plot(x, result.best_fit, '-', label='best fit')
[<matplotlib.lines.Line2D at 0x222c5c47d10>]
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import griddata
import os
from os.path import join as join
import lmfit
from lmfit.lineshapes import gaussian2d, lorentzian
from PIL import Image
# Load the image
run_folder = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\VeffMeasurements\Sept26Dispensation"
for i, img in enumerate(os.listdir(run_folder)[:4]):
if '0p76' in img:
image_path = join(run_folder, img)
image = Image.open(image_path)
# Convert the image to a numpy array
image_array = np.array(image, dtype=float)
plot_data = image_array[32, 40:]
plot_data = plot_data - plot_data[-1]
y = plot_data
x = np.arange(len(plot_data))
model = lmfit.models.GaussianModel()
params = model.guess(y, x=x)
result = model.fit(y, x=x, params=params)
result.fit_report()
plt.plot(x, y)
plt.plot(x, result.init_fit, '--', label='initial fit')
plt.plot(x, result.best_fit, '-', label='best fit')
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import griddata
import os
from os.path import join as join
import lmfit
from lmfit.lineshapes import gaussian2d, lorentzian
from PIL import Image
# Load the image
run_folder = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\VeffMeasurements\Sept26Dispensation"
for i, img in enumerate(os.listdir(run_folder)[:5]):
if '0p76' in img:
image_path = join(run_folder, img)
image = Image.open(image_path)
# Convert the image to a numpy array
image_array = np.array(image, dtype=float)
plot_data = image_array[32, 40:]
plot_data = plot_data - plot_data[-1]
y = plot_data
x = np.arange(len(plot_data))
model = lmfit.models.GaussianModel()
params = model.guess(y, x=x)
result = model.fit(y, x=x, params=params)
result.fit_report()
plt.plot(x, y)
plt.plot(x, result.init_fit, '--', label='initial fit')
plt.plot(x, result.best_fit, '-', label='best fit')
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import griddata
import os
from os.path import join as join
import lmfit
from lmfit.lineshapes import gaussian2d, lorentzian
from PIL import Image
# Load the image
run_folder = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\VeffMeasurements\Sept26Dispensation"
for i, img in enumerate(os.listdir(run_folder)[:6]):
if '0p76' in img:
image_path = join(run_folder, img)
image = Image.open(image_path)
# Convert the image to a numpy array
image_array = np.array(image, dtype=float)
plot_data = image_array[32, 40:]
plot_data = plot_data - plot_data[-1]
y = plot_data
x = np.arange(len(plot_data))
model = lmfit.models.GaussianModel()
params = model.guess(y, x=x)
result = model.fit(y, x=x, params=params)
result.fit_report()
plt.plot(x, y)
plt.plot(x, result.init_fit, '--', label='initial fit')
plt.plot(x, result.best_fit, '-', label='best fit')
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import griddata
import os
from os.path import join as join
import lmfit
from lmfit.lineshapes import gaussian2d, lorentzian
from PIL import Image
# Load the image
run_folder = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\VeffMeasurements\Sept26Dispensation"
for i, img in enumerate(os.listdir(run_folder)[:6]):
if '0p76' in img:
image_path = join(run_folder, img)
image = Image.open(image_path)
# Convert the image to a numpy array
image_array = np.array(image, dtype=float)
plot_data = image_array[32, 40:]
plot_data = plot_data - plot_data[-1]
y = plot_data
x = np.arange(len(plot_data))
model = lmfit.models.GaussianModel()
params = model.guess(y, x=x)
result = model.fit(y, x=x, params=params)
result.fit_report()
plt.plot(x, y)
plt.plot(x, result.best_fit, '-', label='best fit')
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import griddata
import os
from os.path import join as join
import lmfit
from lmfit.lineshapes import gaussian2d, lorentzian
from PIL import Image
# Load the image
run_folder = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\VeffMeasurements\Sept26Dispensation"
for i, img in enumerate(os.listdir(run_folder)[:10]):
if '0p76' in img:
image_path = join(run_folder, img)
image = Image.open(image_path)
# Convert the image to a numpy array
image_array = np.array(image, dtype=float)
plot_data = image_array[32, 40:]
plot_data = plot_data - plot_data[-1]
y = plot_data
x = np.arange(len(plot_data))
model = lmfit.models.GaussianModel()
params = model.guess(y, x=x)
result = model.fit(y, x=x, params=params)
result.fit_report()
plt.plot(x, y)
plt.plot(x, result.best_fit, '-', label='best fit')
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import griddata
import os
from os.path import join as join
import lmfit
from lmfit.lineshapes import gaussian2d, lorentzian
from PIL import Image
# Load the image
run_folder = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\VeffMeasurements\Sept26Dispensation"
for i, img in enumerate(os.listdir(run_folder)[:10]):
if '0p76' in img:
image_path = join(run_folder, img)
image = Image.open(image_path)
# Convert the image to a numpy array
image_array = np.array(image, dtype=float)
plot_data = image_array[32, 40:]
plot_data = plot_data - plot_data[-1]
y = plot_data
x = np.arange(len(plot_data))
model = lmfit.models.GaussianModel()
params = model.guess(y, x=x)
result = model.fit(y, x=x, params=params)
result.fit_report()
#plt.plot(x, y)
plt.plot(x, result.best_fit, '-', label='best fit')
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import griddata
import os
from os.path import join as join
import lmfit
from lmfit.lineshapes import gaussian2d, lorentzian
from PIL import Image
# Load the image
run_folder = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\VeffMeasurements\Sept26Dispensation"
for i, img in enumerate(os.listdir(run_folder)[:10]):
if '0p76' in img:
image_path = join(run_folder, img)
image = Image.open(image_path)
# Convert the image to a numpy array
image_array = np.array(image, dtype=float)
plot_data = image_array[32, 40:]
plot_data = plot_data - plot_data[-1]
y = plot_data
x = np.arange(len(plot_data))
model = lmfit.models.GaussianModel()
params = model.guess(y, x=x)
result = model.fit(y, x=x, params=params)
result.fit_report()
#plt.plot(x, y)
plt.plot(x, result.best_fit, '-', label=f'{result.params['sigma']}')
Cell In[97], line 33 plt.plot(x, result.best_fit, '-', label=f'{result.params['sigma']}') ^ SyntaxError: f-string: unmatched '['
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import griddata
import os
from os.path import join as join
import lmfit
from lmfit.lineshapes import gaussian2d, lorentzian
from PIL import Image
# Load the image
run_folder = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\VeffMeasurements\Sept26Dispensation"
for i, img in enumerate(os.listdir(run_folder)[:10]):
if '0p76' in img:
image_path = join(run_folder, img)
image = Image.open(image_path)
# Convert the image to a numpy array
image_array = np.array(image, dtype=float)
plot_data = image_array[32, 40:]
plot_data = plot_data - plot_data[-1]
y = plot_data
x = np.arange(len(plot_data))
model = lmfit.models.GaussianModel()
params = model.guess(y, x=x)
result = model.fit(y, x=x, params=params)
result.fit_report()
#plt.plot(x, y)
plt.plot(x, result.best_fit, '-', label=f"{result.params['sigma']}")
plt.legend()
<matplotlib.legend.Legend at 0x222c7693ad0>
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import griddata
import os
from os.path import join as join
import lmfit
from lmfit.lineshapes import gaussian2d, lorentzian
from PIL import Image
# Load the image
run_folder = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\VeffMeasurements\Sept26Dispensation"
for i, img in enumerate(os.listdir(run_folder)[:10]):
if '0p76' in img:
image_path = join(run_folder, img)
image = Image.open(image_path)
# Convert the image to a numpy array
image_array = np.array(image, dtype=float)
plot_data = image_array[32, 40:]
plot_data = plot_data - plot_data[-1]
y = plot_data
x = np.arange(len(plot_data))
model = lmfit.models.GaussianModel()
params = model.guess(y, x=x)
result = model.fit(y, x=x, params=params)
result.fit_report()
#plt.plot(x, y)
plt.plot(x, result.best_fit, '-', label=f"{result.params['sigma'].value}")
plt.legend()
<matplotlib.legend.Legend at 0x222c9b71810>
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import griddata
import os
from os.path import join as join
import lmfit
from lmfit.lineshapes import gaussian2d, lorentzian
from PIL import Image
# Load the image
run_folder = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\VeffMeasurements\Sept26Dispensation"
for i, img in enumerate(os.listdir(run_folder)[:10]):
if '0p76' in img:
image_path = join(run_folder, img)
image = Image.open(image_path)
# Convert the image to a numpy array
image_array = np.array(image, dtype=float)
plot_data = image_array[32, 40:]
plot_data = plot_data - plot_data[-1]
y = plot_data
x = np.arange(len(plot_data))
model = lmfit.models.GaussianModel()
params = model.guess(y, x=x)
result = model.fit(y, x=x, params=params)
result.fit_report()
#plt.plot(x, y)
plt.plot(x, result.best_fit, '-', label=fr"$\sigma$ = {result.params['sigma'].value:.2f}")
plt.legend()
<matplotlib.legend.Legend at 0x222c9b76290>
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import griddata
import os
from os.path import join as join
import lmfit
from lmfit.lineshapes import gaussian2d, lorentzian
from PIL import Image
# Load the image
run_folder = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\VeffMeasurements\Sept26Dispensation"
for i, img in enumerate(os.listdir(run_folder)[:10]):
if '0p76' in img:
image_path = join(run_folder, img)
image = Image.open(image_path)
# Convert the image to a numpy array
image_array = np.array(image, dtype=float)
plot_data = image_array[32, 40:]
plot_data = plot_data - plot_data[-1]
y = plot_data
x = np.arange(len(plot_data))
model = lmfit.models.GaussianModel()
params = model.guess(y, x=x)
result = model.fit(y, x=x, params=params)
result.fit_report()
plt.plot(x, y)
plt.plot(x, result.best_fit, '-', label=fr"$\sigma$ = {result.params['sigma'].value:.2f}")
plt.legend()
<matplotlib.legend.Legend at 0x222c9fb8bd0>
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import griddata
import os
from os.path import join as join
import lmfit
from lmfit.lineshapes import gaussian2d, lorentzian
from PIL import Image
# Load the image
run_folder = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\VeffMeasurements\Sept26Dispensation"
for i, img in enumerate(os.listdir(run_folder)[:10]):
if '0p76' in img:
image_path = join(run_folder, img)
image = Image.open(image_path)
# Convert the image to a numpy array
image_array = np.array(image, dtype=float)
plot_data = image_array[32, 40:]
plot_data = plot_data/plot_data[-1]
y = plot_data
x = np.arange(len(plot_data))
model = lmfit.models.GaussianModel()
params = model.guess(y, x=x)
result = model.fit(y, x=x, params=params)
result.fit_report()
plt.plot(x, y)
plt.plot(x, result.best_fit, '-', label=fr"$\sigma$ = {result.params['sigma'].value:.2f}")
plt.legend()
<matplotlib.legend.Legend at 0x222ca04a950>
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import griddata
import os
from os.path import join as join
import lmfit
from lmfit.lineshapes import gaussian2d, lorentzian
from PIL import Image
# Load the image
run_folder = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\VeffMeasurements\Sept26Dispensation"
for i, img in enumerate(os.listdir(run_folder)[:10]):
if '0p76' in img:
image_path = join(run_folder, img)
image = Image.open(image_path)
# Convert the image to a numpy array
image_array = np.array(image, dtype=float)
plot_data = image_array[32, 40:]
plot_data = plot_data- plot_data[-1]
y = plot_data
x = np.arange(len(plot_data))
model = lmfit.models.GaussianModel()
params = model.guess(y, x=x)
result = model.fit(y, x=x, params=params)
result.fit_report()
plt.plot(x, y)
plt.plot(x, result.best_fit, '-', label=fr"$\sigma$ = {result.params['sigma'].value:.2f}")
plt.legend()
<matplotlib.legend.Legend at 0x222c9fd66d0>
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import griddata
import os
from os.path import join as join
import lmfit
from lmfit.lineshapes import gaussian2d, lorentzian
from PIL import Image
# Load the image
run_folder = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\VeffMeasurements\Sept26Dispensation"
for i, img in enumerate(os.listdir(run_folder)[:10]):
if '0p76' in img:
image_path = join(run_folder, img)
image = Image.open(image_path)
# Convert the image to a numpy array
image_array = np.array(image, dtype=float)
plot_data = image_array[32, 40:]
plot_data = plot_data- np.mean(plot_data[0:10])
y = plot_data
x = np.arange(len(plot_data))
model = lmfit.models.GaussianModel()
params = model.guess(y, x=x)
result = model.fit(y, x=x, params=params)
result.fit_report()
plt.plot(x, y)
plt.plot(x, result.best_fit, '-', label=fr"$\sigma$ = {result.params['sigma'].value:.2f}")
plt.legend()
<matplotlib.legend.Legend at 0x222ca0f4990>
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import griddata
import os
from os.path import join as join
import lmfit
from lmfit.lineshapes import gaussian2d, lorentzian
from PIL import Image
# Load the image
run_folder = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\VeffMeasurements\Sept26Dispensation"
for i, img in enumerate(os.listdir(run_folder)[:10]):
if '0p76' in img:
image_path = join(run_folder, img)
image = Image.open(image_path)
# Convert the image to a numpy array
image_array = np.array(image, dtype=float)
plot_data = image_array[32, 40:]
plot_data = plot_data- np.mean(plot_data[0:10])
y = plot_data
x = np.arange(len(plot_data))
model = lmfit.models.GaussianModel()
params = model.guess(y, x=x)
result = model.fit(y, x=x, params=params)
result.fit_report()
plt.plot(x, y, color=f'C{i}')
plt.plot(x, result.best_fit, '-', label=fr"$\sigma$ = {result.params['sigma'].value:.2f}", color=f'C{i}')
plt.legend()
<matplotlib.legend.Legend at 0x222c9accc50>
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import griddata
import os
from os.path import join as join
import lmfit
from lmfit.lineshapes import gaussian2d, lorentzian
from PIL import Image
# Load the image
run_folder = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\VeffMeasurements\Sept26Dispensation"
for i, img in enumerate(os.listdir(run_folder)[:10]):
if '0p76' in img:
image_path = join(run_folder, img)
image = Image.open(image_path)
# Convert the image to a numpy array
image_array = np.array(image, dtype=float)
plot_data = image_array[32, 40:]
plot_data = plot_data- np.mean(plot_data[0:8])
y = plot_data
x = np.arange(len(plot_data))
model = lmfit.models.GaussianModel()
params = model.guess(y, x=x)
result = model.fit(y, x=x, params=params)
result.fit_report()
plt.plot(x, y, color=f'C{i}')
plt.plot(x, result.best_fit, '-', label=fr"$\sigma$ = {result.params['sigma'].value:.2f}", color=f'C{i}')
plt.legend()
<matplotlib.legend.Legend at 0x222ca59b010>
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import griddata
import os
from os.path import join as join
import lmfit
from lmfit.lineshapes import gaussian2d, lorentzian
from PIL import Image
# Load the image
run_folder = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\VeffMeasurements\Sept26Dispensation"
for i, img in enumerate(os.listdir(run_folder)[:10]):
if '0p76' in img:
image_path = join(run_folder, img)
image = Image.open(image_path)
# Convert the image to a numpy array
image_array = np.array(image, dtype=float)
plot_data = image_array[32, 40:]
plot_data = plot_data- np.mean(plot_data[0:7])
y = plot_data
x = np.arange(len(plot_data))
model = lmfit.models.GaussianModel()
params = model.guess(y, x=x)
result = model.fit(y, x=x, params=params)
result.fit_report()
plt.plot(x, y, color=f'C{i}')
plt.plot(x, result.best_fit, '-', label=fr"$\sigma$ = {result.params['sigma'].value:.2f}", color=f'C{i}')
plt.legend()
<matplotlib.legend.Legend at 0x222ca561b10>
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import griddata
import os
from os.path import join as join
import lmfit
from lmfit.lineshapes import gaussian2d, lorentzian
from PIL import Image
# Load the image
run_folder = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\VeffMeasurements\Sept26Dispensation"
for i, img in enumerate(os.listdir(run_folder)[:8]):
if '0p76' in img:
image_path = join(run_folder, img)
image = Image.open(image_path)
# Convert the image to a numpy array
image_array = np.array(image, dtype=float)
plot_data = image_array[32, 40:]
plot_data = plot_data- np.mean(plot_data[0:10])
y = plot_data
x = np.arange(len(plot_data))
model = lmfit.models.GaussianModel()
params = model.guess(y, x=x)
result = model.fit(y, x=x, params=params)
result.fit_report()
plt.plot(x, y, color=f'C{i}')
plt.plot(x, result.best_fit, '-', label=fr"$\sigma$ = {result.params['sigma'].value:.2f}", color=f'C{i}')
plt.legend()
<matplotlib.legend.Legend at 0x222ca843010>
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import griddata
import os
from os.path import join as join
import lmfit
from lmfit.lineshapes import gaussian2d, lorentzian
from PIL import Image
# Load the image
run_folder = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\VeffMeasurements\Sept26Dispensation"
for i, img in enumerate(os.listdir(run_folder)[:7]):
if '0p76' in img:
image_path = join(run_folder, img)
image = Image.open(image_path)
# Convert the image to a numpy array
image_array = np.array(image, dtype=float)
plot_data = image_array[32, 40:]
plot_data = plot_data- np.mean(plot_data[0:10])
y = plot_data
x = np.arange(len(plot_data))
model = lmfit.models.GaussianModel()
params = model.guess(y, x=x)
result = model.fit(y, x=x, params=params)
result.fit_report()
plt.plot(x, y, color=f'C{i}')
plt.plot(x, result.best_fit, '-', label=fr"$\sigma$ = {result.params['sigma'].value:.2f}", color=f'C{i}')
plt.legend()
<matplotlib.legend.Legend at 0x222ca832f50>
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import griddata
import os
from os.path import join as join
import lmfit
from lmfit.lineshapes import gaussian2d, lorentzian
from PIL import Image
# Load the image
run_folder = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\VeffMeasurements\Sept26Dispensation"
for i, img in enumerate(os.listdir(run_folder)[:6]):
if '0p76' in img:
image_path = join(run_folder, img)
image = Image.open(image_path)
# Convert the image to a numpy array
image_array = np.array(image, dtype=float)
plot_data = image_array[32, 40:]
plot_data = plot_data- np.mean(plot_data[0:10])
y = plot_data
x = np.arange(len(plot_data))
model = lmfit.models.GaussianModel()
params = model.guess(y, x=x)
result = model.fit(y, x=x, params=params)
result.fit_report()
plt.plot(x, y, color=f'C{i}')
plt.plot(x, result.best_fit, '-', label=fr"$\sigma$ = {result.params['sigma'].value:.2f}", color=f'C{i}')
plt.legend()
<matplotlib.legend.Legend at 0x222c9b0c650>
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import griddata
import os
from os.path import join as join
import lmfit
from lmfit.lineshapes import gaussian2d, lorentzian
from PIL import Image
# Load the image
run_folder = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\VeffMeasurements\Sept26Dispensation"
for i, img in enumerate(os.listdir(run_folder)[:]):
if '1p4' in img:
image_path = join(run_folder, img)
image = Image.open(image_path)
# Convert the image to a numpy array
image_array = np.array(image, dtype=float)
plot_data = image_array[32, 40:]
plot_data = plot_data- np.mean(plot_data[0:10])
y = plot_data
x = np.arange(len(plot_data))
model = lmfit.models.GaussianModel()
params = model.guess(y, x=x)
result = model.fit(y, x=x, params=params)
result.fit_report()
plt.plot(x, y, color=f'C{i}')
plt.plot(x, result.best_fit, '-', label=fr"$\sigma$ = {result.params['sigma'].value:.2f}", color=f'C{i}')
plt.legend()
<matplotlib.legend.Legend at 0x222cab6c2d0>
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import griddata
import os
from os.path import join as join
import lmfit
from lmfit.lineshapes import gaussian2d, lorentzian
from PIL import Image
# Load the image
run_folder = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\VeffMeasurements\Sept26Dispensation"
for i, img in enumerate(os.listdir(run_folder)[:]):
if '1p85' in img:
image_path = join(run_folder, img)
image = Image.open(image_path)
# Convert the image to a numpy array
image_array = np.array(image, dtype=float)
plot_data = image_array[32, 40:]
plot_data = plot_data- np.mean(plot_data[0:10])
y = plot_data
x = np.arange(len(plot_data))
model = lmfit.models.GaussianModel()
params = model.guess(y, x=x)
result = model.fit(y, x=x, params=params)
result.fit_report()
plt.plot(x, y, color=f'C{i}')
plt.plot(x, result.best_fit, '-', label=fr"$\sigma$ = {result.params['sigma'].value:.2f}", color=f'C{i}')
plt.legend()
<matplotlib.legend.Legend at 0x222cac2b010>
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import griddata
import os
from os.path import join as join
import lmfit
from lmfit.lineshapes import gaussian2d, lorentzian
from PIL import Image
# Load the image
run_folder = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\VeffMeasurements\Sept26Dispensation"
for i, img in enumerate(os.listdir(run_folder)[:]):
if '_84_' in img:
image_path = join(run_folder, img)
image = Image.open(image_path)
# Convert the image to a numpy array
image_array = np.array(image, dtype=float)
plot_data = image_array[32, 40:]
plot_data = plot_data- np.mean(plot_data[0:10])
y = plot_data
x = np.arange(len(plot_data))
model = lmfit.models.GaussianModel()
params = model.guess(y, x=x)
result = model.fit(y, x=x, params=params)
result.fit_report()
plt.plot(x, y, color=f'C{i}')
plt.plot(x, result.best_fit, '-', label=fr"$\sigma$ = {result.params['sigma'].value:.2f}", color=f'C{i}')
plt.legend()
<matplotlib.legend.Legend at 0x222cbcaa950>
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import griddata
import os
from os.path import join as join
import lmfit
from lmfit.lineshapes import gaussian2d, lorentzian
from PIL import Image
# Load the image
run_folder = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\VeffMeasurements\Sept26Dispensation"
for i, img in enumerate(os.listdir(run_folder)[:]):
if '_83_' in img:
image_path = join(run_folder, img)
image = Image.open(image_path)
# Convert the image to a numpy array
image_array = np.array(image, dtype=float)
plot_data = image_array[32, 40:]
plot_data = plot_data- np.mean(plot_data[0:10])
y = plot_data
x = np.arange(len(plot_data))
model = lmfit.models.GaussianModel()
params = model.guess(y, x=x)
result = model.fit(y, x=x, params=params)
result.fit_report()
plt.plot(x, y, color=f'C{i}')
plt.plot(x, result.best_fit, '-', label=fr"$\sigma$ = {result.params['sigma'].value:.2f}", color=f'C{i}')
plt.legend()
<matplotlib.legend.Legend at 0x222cbd6a150>
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import griddata
import os
from os.path import join as join
import lmfit
from lmfit.lineshapes import gaussian2d, lorentzian
from PIL import Image
# Load the image
run_folder = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\VeffMeasurements\Sept26Dispensation"
j=0
for i, img in enumerate(os.listdir(run_folder)[:]):
if '_83_' in img:
j = j +1
image_path = join(run_folder, img)
image = Image.open(image_path)
# Convert the image to a numpy array
image_array = np.array(image, dtype=float)
plot_data = image_array[32, 40:]
plot_data = plot_data- np.mean(plot_data[0:10])
y = plot_data
x = np.arange(len(plot_data))
model = lmfit.models.GaussianModel()
params = model.guess(y, x=x)
result = model.fit(y, x=x, params=params)
result.fit_report()
plt.plot(x, y, color=f'C{j}')
plt.plot(x, result.best_fit, '-', label=fr"$\sigma$ = {result.params['sigma'].value:.2f}", color=f'C{j}')
plt.legend()
<matplotlib.legend.Legend at 0x222cbd30510>
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import griddata
import os
from os.path import join as join
import lmfit
from lmfit.lineshapes import gaussian2d, lorentzian
from PIL import Image
# Load the image
run_folder = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\VeffMeasurements\Sept26Dispensation"
j=0
for i, img in enumerate(os.listdir(run_folder)[:]):
if '_83_' in img:
j = j +1
image_path = join(run_folder, img)
image = Image.open(image_path)
# Convert the image to a numpy array
image_array = np.array(image, dtype=float)
plot_data = image_array[32, 40:]
plot_data = plot_data- np.mean(plot_data[0:10])
y = plot_data
x = np.arange(len(plot_data))
model = lmfit.models.GaussianModel()
params = model.guess(y, x=x)
result = model.fit(y, x=x, params=params)
result.fit_report()
plt.plot(x, y, color=f'C{j}')
plt.plot(x, result.best_fit, '-', label=fr"$\sigma$ = {result.params['sigma'].value:.2f}, name = {img}", color=f'C{j}')
plt.legend()
<matplotlib.legend.Legend at 0x222cc142950>
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import griddata
import os
from os.path import join as join
import lmfit
from lmfit.lineshapes import gaussian2d, lorentzian
from PIL import Image
# Load the image
run_folder = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\VeffMeasurements\Sept26Dispensation"
j=0
for i, img in enumerate(os.listdir(run_folder)[:]):
if '_83_' in img:
j = j +1
image_path = join(run_folder, img)
image = Image.open(image_path)
# Convert the image to a numpy array
image_array = np.array(image, dtype=float)
plot_data = image_array[32, 40:]
plot_data = plot_data- np.mean(plot_data[0:10])
y = plot_data
x = np.arange(len(plot_data))
model = lmfit.models.GaussianModel()
params = model.guess(y, x=x)
result = model.fit(y, x=x, params=params)
result.fit_report()
plt.plot(x, y, color=f'C{j}', 'o')
plt.plot(x, result.best_fit, '-', label=fr"$\sigma$ = {result.params['sigma'].value:.2f}, name = {img}", color=f'C{j}')
plt.legend()
Cell In[118], line 34 plt.plot(x, y, color=f'C{j}', 'o') ^ SyntaxError: positional argument follows keyword argument
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import griddata
import os
from os.path import join as join
import lmfit
from lmfit.lineshapes import gaussian2d, lorentzian
from PIL import Image
# Load the image
run_folder = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\VeffMeasurements\Sept26Dispensation"
j=0
for i, img in enumerate(os.listdir(run_folder)[:]):
if '_83_' in img:
j = j +1
image_path = join(run_folder, img)
image = Image.open(image_path)
# Convert the image to a numpy array
image_array = np.array(image, dtype=float)
plot_data = image_array[32, 40:]
plot_data = plot_data- np.mean(plot_data[0:10])
y = plot_data
x = np.arange(len(plot_data))
model = lmfit.models.GaussianModel()
params = model.guess(y, x=x)
result = model.fit(y, x=x, params=params)
result.fit_report()
plt.plot(x, y, 'o', color=f'C{j}' )
plt.plot(x, result.best_fit, '-', label=fr"$\sigma$ = {result.params['sigma'].value:.2f}, name = {img}", color=f'C{j}')
plt.legend()
<matplotlib.legend.Legend at 0x222cd366e50>
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import griddata
import os
from os.path import join as join
import lmfit
from lmfit.lineshapes import gaussian2d, lorentzian
from PIL import Image
# Load the image
run_folder = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\VeffMeasurements\Sept26Dispensation"
j=0
for i, img in enumerate(os.listdir(run_folder)[:]):
if '_83_' in img:
j = j +1
image_path = join(run_folder, img)
image = Image.open(image_path)
# Convert the image to a numpy array
image_array = np.array(image, dtype=float)
plot_data = image_array[:, 63]
plot_data = plot_data- np.mean(plot_data[0:10])
y = plot_data
x = np.arange(len(plot_data))
model = lmfit.models.GaussianModel()
params = model.guess(y, x=x)
result = model.fit(y, x=x, params=params)
result.fit_report()
plt.plot(x, y, 'o', color=f'C{j}' )
plt.plot(x, result.best_fit, '-', label=fr"$\sigma$ = {result.params['sigma'].value:.2f}, name = {img}", color=f'C{j}')
plt.legend()
<matplotlib.legend.Legend at 0x222cd1bd910>
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import griddata
import os
from os.path import join as join
import lmfit
from lmfit.lineshapes import gaussian2d, lorentzian
from PIL import Image
# Load the image
run_folder = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\VeffMeasurements\Sept26Dispensation"
j=0
for i, img in enumerate(os.listdir(run_folder)[:]):
if '_83_' in img:
j = j +1
image_path = join(run_folder, img)
image = Image.open(image_path)
# Convert the image to a numpy array
image_array = np.array(image, dtype=float)
plot_data = image_array[:, 65]
plot_data = plot_data- np.mean(plot_data[0:10])
y = plot_data
x = np.arange(len(plot_data))
model = lmfit.models.GaussianModel()
params = model.guess(y, x=x)
result = model.fit(y, x=x, params=params)
result.fit_report()
plt.plot(x, y, 'o', color=f'C{j}' )
plt.plot(x, result.best_fit, '-', label=fr"$\sigma$ = {result.params['sigma'].value:.2f}, name = {img}", color=f'C{j}')
plt.legend()
<matplotlib.legend.Legend at 0x222cd715e50>
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import griddata
import os
from os.path import join as join
import lmfit
from lmfit.lineshapes import gaussian2d, lorentzian
from PIL import Image
# Load the image
run_folder = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\VeffMeasurements\Sept26Dispensation"
j=0
for i, img in enumerate(os.listdir(run_folder)[:]):
if '_83_' in img:
j = j +1
image_path = join(run_folder, img)
image = Image.open(image_path)
# Convert the image to a numpy array
image_array = np.array(image, dtype=float)
plot_data = image_array[:, 70]
plot_data = plot_data- np.mean(plot_data[0:10])
y = plot_data
x = np.arange(len(plot_data))
model = lmfit.models.GaussianModel()
params = model.guess(y, x=x)
result = model.fit(y, x=x, params=params)
result.fit_report()
plt.plot(x, y, 'o', color=f'C{j}' )
plt.plot(x, result.best_fit, '-', label=fr"$\sigma$ = {result.params['sigma'].value:.2f}, name = {img}", color=f'C{j}')
plt.legend()
<matplotlib.legend.Legend at 0x222cd68af10>
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import griddata
import os
from os.path import join as join
import lmfit
from lmfit.lineshapes import gaussian2d, lorentzian
from PIL import Image
# Load the image
run_folder = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\VeffMeasurements\Sept26Dispensation"
j=0
for i, img in enumerate(os.listdir(run_folder)[:]):
if '_83_' in img:
j = j +1
image_path = join(run_folder, img)
image = Image.open(image_path)
# Convert the image to a numpy array
image_array = np.array(image, dtype=float)
plot_data = image_array[:60, 70]
plot_data = plot_data- np.mean(plot_data[0:10])
y = plot_data
x = np.arange(len(plot_data))
model = lmfit.models.GaussianModel()
params = model.guess(y, x=x)
result = model.fit(y, x=x, params=params)
result.fit_report()
plt.plot(x, y, 'o', color=f'C{j}' )
plt.plot(x, result.best_fit, '-', label=fr"$\sigma$ = {result.params['sigma'].value:.2f}, name = {img}", color=f'C{j}')
plt.legend()
<matplotlib.legend.Legend at 0x222cd8bde50>
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import griddata
import os
from os.path import join as join
import lmfit
from lmfit.lineshapes import gaussian2d, lorentzian
from PIL import Image
# Load the image
run_folder = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\VeffMeasurements\Sept26Dispensation"
j=0
for i, img in enumerate(os.listdir(run_folder)[:]):
if '_83_' in img:
j = j +1
image_path = join(run_folder, img)
image = Image.open(image_path)
# Convert the image to a numpy array
image_array = np.array(image, dtype=float)
plot_data = image_array[:60, 70]
plot_data = plot_data- np.mean(plot_data[0:10])
y = plot_data
x = np.arange(len(plot_data))
model = lmfit.models.GaussianModel()
params = model.guess(y, x=x)
result = model.fit(y, x=x, params=params)
result.fit_report()
plt.plot(x, y, 'o', color=f'C{j}' )
plt.plot(x, result.best_fit, '-', label=fr"$\sigma$ = {result.params['sigma'].value:.2f}, name = {img}", color=f'C{j}')
plt.legend(bbox_to_anchor = [1.5, 1.5])
<matplotlib.legend.Legend at 0x222cd0e1d90>
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import griddata
import os
from os.path import join as join
import lmfit
from lmfit.lineshapes import gaussian2d, lorentzian
from PIL import Image
# Load the image
run_folder = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\VeffMeasurements\Sept26Dispensation"
j=0
for i, img in enumerate(os.listdir(run_folder)[:]):
if '_83_' in img:
j = j +1
image_path = join(run_folder, img)
image = Image.open(image_path)
# Convert the image to a numpy array
image_array = np.array(image, dtype=float)
plot_data = image_array[:63, 70]
plot_data = plot_data- np.mean(plot_data[0:10])
y = plot_data
x = np.arange(len(plot_data))
model = lmfit.models.GaussianModel()
params = model.guess(y, x=x)
result = model.fit(y, x=x, params=params)
result.fit_report()
plt.plot(x, y, 'o', color=f'C{j}' )
plt.plot(x, result.best_fit, '-', label=fr"$\sigma$ = {result.params['sigma'].value:.2f}, name = {img}", color=f'C{j}')
plt.legend(bbox_to_anchor = [1.5, 1.5])
<matplotlib.legend.Legend at 0x222cdf35e50>
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import griddata
import os
from os.path import join as join
import lmfit
from lmfit.lineshapes import gaussian2d, lorentzian
from PIL import Image
# Load the image
run_folder = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\VeffMeasurements\Sept26Dispensation"
j=0
for i, img in enumerate(os.listdir(run_folder)[:]):
if '_83_' in img:
j = j +1
image_path = join(run_folder, img)
image = Image.open(image_path)
# Convert the image to a numpy array
image_array = np.array(image, dtype=float)
plot_data = image_array[:63, 70]
plot_data = plot_data- np.mean(plot_data[0:10])
y = plot_data
x = np.arange(len(plot_data))
model = lmfit.models.GaussianModel()
params = model.guess(y, x=x)
result = model.fit(y, x=x, params=params)
result.fit_report()
plt.plot(x, y, 'o', color=f'C{j}', markersize=3 )
plt.plot(x, result.best_fit, '-', label=fr"$\sigma$ = {result.params['sigma'].value:.2f}, name = {img}", color=f'C{j}')
plt.legend(bbox_to_anchor = [1.5, 1.5])
<matplotlib.legend.Legend at 0x222cdf54e90>